/*
 * @Descripttion:
 * @Version: 1.0
 * @Author: undead
 * @Date: 2021-03-25 15:02:58
 * @LastEditors: undead
 * @LastEditTime: 2021-03-29 14:28:37
 */
const TerserWebpackPlugin = require("terser-webpack-plugin");

module.exports = {
  mode: "none",
  devtool: "source-map",
  entry: {
    zlogs: "./src/index.ts",
    "zlogs.min": "./src/index.ts",
  },
  output: {
    filename: "[name].js",
    library: "zlogs", // 指定库的名称，及库的全局变量
    libraryTarget: "umd", // 支持库引入的方式
    libraryExport: "default",
  },
  resolve: {
    extensions: [".ts", ".tsx", ".js"],
  },
  module: {
    rules: [
      {
        test: /\.ts?$/,
        exclude: /node_modules/,
        loader: "ts-loader",
      },
    ],
  },
  optimization: {
    minimize: true,
    minimizer: [
      new TerserWebpackPlugin({
        include: /\.min\.js$/,
      }),
    ],
  },
};
